
package org.springframework.aop.framework.adapter;

import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;

import org.springframework.aop.Advisor;

/**
 * spring aop框架对BeforeAdvice、AfterAdvice、ThrowsAdvice三种通知类型的支持实际上是借助适配器模式来实现的，
 * 这样的好处是使得框架允许用户向框架中加入自己想要支持的任何一种通知类型的AdvisorAdapter是一个适配器接口，
 * 它定义了自己支持的Advice类型，并且能把一个Advisor适配成 MethodInterceptor（这也是AOP联盟定义的 接口)
 *
 * @author Rod Johnson
 */
public interface AdvisorAdapter {

	/**
	 * 判断此适配器是否支持特定的Advice
	 *
	 * @param advice an Advice such as a BeforeAdvice
	 * @return whether this adapter understands the given advice object
	 * @see #getInterceptor(org.springframework.aop.Advisor)
	 * @see org.springframework.aop.BeforeAdvice
	 */
	boolean supportsAdvice(Advice advice);

	/**
	 * 将一个Advisor适配成MethodInterceptor
	 */
	MethodInterceptor getInterceptor(Advisor advisor);

}
